home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
midi
/
gfft.lha
/
gfft-2.03
/
source
/
gfft-2.03-source.lha
/
gmalloc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-02
|
2KB
|
64 lines
/***************************************************************************
* Copyright (C) 1994 Charles P. Peterson *
* 4007 Enchanted Sun, San Antonio, Texas 78244-1254 *
* Email: Charles_P_Peterson@fcircus.sat.tx.us *
* *
* This is free software with NO WARRANTY. *
* See gfft.c, or run program itself, for details. *
* Support is available for a fee. *
***************************************************************************
*
* Program: gfft--General FFT analysis
* File: galloc.c
* Purpose: memory allocation
* Author: Charles Peterson (CPP)
* History: 2-June-1993 CPP; Created.
* Comments: These are layer(s) on top of malloc and free.
* If system doesn't automatically deallocate memory on exit()
* special handling could be added here.
* If malloc fails, longjmp is called to return to main loop
* in gfft, or a more recent setjmp.
*/
#include <stdlib.h>
#include "gfft.h"
void* gmalloc (unsigned long bytes, int jmp_value)
{
void *memblock = malloc ((size_t) bytes);
if (!memblock)
{
error_message (OUT_OF_MEMORY);
RAISE_ERROR (jmp_value);
}
return memblock;
}
void* grealloc (void *memblock, unsigned long bytes, int jmp_value)
{
memblock = realloc (memblock, (size_t) bytes);
if (!memblock)
{
error_message (OUT_OF_MEMORY);
RAISE_ERROR (jmp_value);
}
return memblock;
}
void* gcalloc (unsigned long n_ele, unsigned long ele_size, int jmp_value)
{
void *memblock = calloc ((size_t) n_ele, (size_t) ele_size);
if (!memblock)
{
error_message (OUT_OF_MEMORY);
RAISE_ERROR (jmp_value);
}
return memblock;
}
void gfree (void* block)
{
free (block);
}